var fn_type="cust";
$(window).ready(function()
{
	//设置容器大小
	set_page_size();
	//设置事件
	set_event();
	//初始化页面
	change_fn();
});
//设置事件
function set_event()
{
	//窗口大小改变
	$(window).resize(function(){set_page_size();});
	//鼠标覆盖顶部菜单
	$(".main_top_menu_text").mouseover(function(){top_menu_mouseover(this);});
	//鼠标离开顶部菜单
	$(".main_top_menu_text").mouseleave(function(){top_menu_mouseleave(this);});
	//鼠标点击
	$(".main_top_menu_text").click(function(){change_fn(this);});
	//安全退出
	$("#main_button_logout").click(function(){main_logout()});

}

//安全退出
function main_logout()
{
	location.href="php/logout.php";
}

function change_fn(div)
{
	if(div)
	{
		$(".main_top_menu_text").css("background","#333333").css("color","#ffffff");
		$(div).css("background","#ececec").css("color","#333333");
		fn_type=$(div).attr("name");
	}
	else if(!div)
	{
		$(".main_top_menu_text").css("background","#333333").css("color","#ffffff");
		$("#button_"+fn_type).css("background","#ececec").css("color","#333333");
	}

	$('#main_fn').attr("src","fn/"+fn_type+".php");
}
//鼠标离开样式
function top_menu_mouseleave(div)
{
	var type=$(div).attr("name");
	if(fn_type!=type)
	{
		$(div).css("background","#333333");
	}
}
//设置鼠标覆盖样式
function top_menu_mouseover(div)
{
	var type=$(div).attr("name");
	if(fn_type!=type)
	{
		$(div).css("background","#666666");
	}
}



//设置容器大小
function set_page_size()
{
	var win=$(window);
	//var body=$("#main_body");
	var ifr=$("#main_fn");
	//获取窗口高度
	var win_height=win.height();
	//获取窗口宽度
	var win_width=win.width();
	//设置iframe的大小
	var ifr_width=win_width-20;
	var ifr_height=win_height-30-80-50-20;	
	//设置iframe的位置
	var ifr_top=80+50+30;
	var ifr_left=10;
	ifr.css("width",ifr_width+"px").css("height",ifr_height+"px").css("top",ifr_top+"px").css("left",ifr_left+"px");
}